package com.csc531.views;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.csc531.DataTypes.Task;



/**
 * @author Javier Figueroa
 * View for the Classes in the ClassesThinList class
 *
 */
public class ClassesView extends LinearLayout 
{
	public ClassesView(Context context, Task task, boolean expanded)
	{
        super(context);

        this.setOrientation(VERTICAL);

        // Here we build the child views in code. They could also have
        // been specified in an XML file.

        mTitle = new TextView(context);
        mTitle.setText(task.getTitle());
        addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

        mDescription = new TextView(context);
        mDescription.setText(task.getDescription());
        addView(mDescription, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

        mDescription.setVisibility(expanded ? VISIBLE : GONE);
    }

    /**
     * Convenience method to set the title of a ClassesView
     */
    public void setTitle(Task task) 
    {
        mTitle.setText(task.getTitle());
    }

    /**
     * Convenience method to set the description of a ClassesView
     */
    public void setDialogue(Task task)
    {
        mDescription.setText(task.getDescription());
    }

    /**
     * Convenience method to expand or hide the description
     */
    public void setExpanded(boolean expanded)
    {
        mDescription.setVisibility(expanded ? VISIBLE : GONE);
    }

    private TextView mTitle;
    private TextView mDescription;
    public int id = 0;
}

